|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
WebDDParser.java | 50% | 78.9% | 66.7% | 72.4% |
|
1 |
/*
|
|
2 |
* Copyright 2001-2004 The Apache Software Foundation.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
|
16 |
|
|
17 |
package org.apache.geronimo.ews.ws4j2ee.parsers;
|
|
18 |
|
|
19 |
import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
|
|
20 |
import org.apache.geronimo.ews.ws4j2ee.context.impl.WebDDContextImpl;
|
|
21 |
import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.WebContext;
|
|
22 |
import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
|
|
23 |
import org.apache.geronimo.ews.ws4j2ee.toWs.UnrecoverableGenerationFault;
|
|
24 |
import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
|
|
25 |
import org.w3c.dom.Document;
|
|
26 |
import org.w3c.dom.Element;
|
|
27 |
import org.w3c.dom.NodeList;
|
|
28 |
|
|
29 |
import java.io.InputStream;
|
|
30 |
|
|
31 |
/**
|
|
32 |
* <web-app> .....
|
|
33 |
* <servlet>
|
|
34 |
* <servlet-name>AxisServlet</servlet-name>
|
|
35 |
* <display-name>Apache-Axis Servlet</display-name>
|
|
36 |
* <servlet-class>
|
|
37 |
* org.apache.axis.transport.http.AxisServlet
|
|
38 |
* </servlet-class>
|
|
39 |
* </servlet>
|
|
40 |
* ...
|
|
41 |
* </web-app>
|
|
42 |
* Parse the web,xl file and get the servlet class corresponds to the given servlet
|
|
43 |
*
|
|
44 |
* @author hemapani
|
|
45 |
*/
|
|
46 |
public class WebDDParser { |
|
47 |
private J2EEWebServiceContext j2eewscontext;
|
|
48 |
private WebContext context;
|
|
49 |
private String servletClass = null; |
|
50 |
private String servletName = null; |
|
51 |
|
|
52 | 4 |
public WebDDParser(J2EEWebServiceContext j2eewscontext) {
|
53 | 4 |
this.j2eewscontext = j2eewscontext;
|
54 |
} |
|
55 |
|
|
56 | 4 |
public void parse(InputStream inputStream) throws GenerationFault { |
57 | 4 |
Document doc = Utils.createDocument(inputStream); |
58 | 4 |
Element root = doc.getDocumentElement(); |
59 | 4 |
NodeList sevlele = root.getElementsByTagName("servlet");
|
60 |
|
|
61 | 4 |
String j2eeLink = j2eewscontext.getMiscInfo().getJ2eeComponetLink(); |
62 | 4 |
int count = 0;
|
63 | 4 |
while (count < sevlele.getLength()) {
|
64 | 4 |
Element serv = (Element) sevlele.item(count); |
65 | 4 |
servletName = Utils.getElementValue(serv.getElementsByTagName("servlet-name"));
|
66 | 4 |
if (servletName.equals(j2eeLink)) {
|
67 | 4 |
servletClass = Utils.getElementValue(serv.getElementsByTagName("servlet-class"));
|
68 | 4 |
context = new WebDDContextImpl(servletClass, servletName);
|
69 | 4 |
return;
|
70 |
} |
|
71 | 0 |
count++; |
72 |
} |
|
73 | 0 |
throw new UnrecoverableGenerationFault("J2EE link not found"); |
74 |
} |
|
75 |
|
|
76 |
/**
|
|
77 |
* @return
|
|
78 |
*/
|
|
79 | 1 |
public String getServletClass() {
|
80 | 1 |
return servletClass;
|
81 |
} |
|
82 |
|
|
83 |
/**
|
|
84 |
* @param string
|
|
85 |
*/
|
|
86 | 0 |
public void setServletClass(String string) { |
87 | 0 |
servletClass = string; |
88 |
} |
|
89 |
|
|
90 |
/**
|
|
91 |
* @return
|
|
92 |
*/
|
|
93 | 3 |
public WebContext getContext() {
|
94 | 3 |
return context;
|
95 |
} |
|
96 |
|
|
97 |
/**
|
|
98 |
* @param context
|
|
99 |
*/
|
|
100 | 0 |
public void setContext(WebContext context) { |
101 | 0 |
this.context = context;
|
102 |
} |
|
103 |
|
|
104 |
} |
|
105 |
|
|